<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta charset="UTF-8">
    <title>点单活动</title>
    <meta name="page-view-size" content="1280*720">
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/common.css">
    <!-- <link rel="stylesheet" href="../css/theory.css"> -->
    <link rel="stylesheet" href="../css/interactive.css">
    <script type="text/javascript" src="../lib/js/evm.js"></script>
    <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
    <script type="text/javascript" src="../lib/js/key.js"></script>
    <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
    <style>
      .nav-bg {
        left: 160px;
      }
      .list-row.active{
        background: #FBC000;
      }
      .list-info .list-view {
        left: 900px;
      }
      .list-info .list-like {
        left: 1000px;
      }

    </style>
</head>

<body>
  <marquee behavior="" direction="">欢迎您进入凤阳县新时代文明实践中心！</marquee>
  <div class="forum-bg" id="forumMain">
      <ul class="nav-bg" id="nav-bg">

      </ul>
      <div class="list-bg">
          <div class="list-con" id="list-con"></div>
          <p class="page-show"><span id="now_page">0</span>/<span id="total_page">0</span>
          </p>
      </div>

  </div>

</body>
<script>
    var modelIndex = {
        index: 0, //导航栏初始位置
        menuKey: '',
        menuPageSize: 6, //导航栏模块数量
        pageSize: 1, //主模块数量
        type: '',
        crumbs: '百姓点单',
        structure: 2, //上下结构  默认1是左右，2是上下结构
        menuContainerId: 'nav-bg', //包含导航栏模块的标签id
        menuListName: 'nav', //导航栏模块名称class
        mainContainerId: 'list-con', //包含主模块的标签id
        mainlistName: '', //主模块名称
        id: 'orderActivity',
    }

    var leftData = [
        {
            name: '百姓点单', //name
            id: '666', //唯一标识
            type_style: '1', //类别
            size: '4', //数量  
            list_name: 'list-row' //右侧模块classname
        },
        {
            name: '经典活动', //name
            id: '32', //唯一标识
            type_style: '1', //类别
            size: '4', //数量  
            list_name: 'list-row' //右侧模块classname
        },
        {
            name: '未开始', //name
            id: '33', //唯一标识
            type_style: '3', //类别
            size: '8', //数量  
            list_name: 'list-row', //右侧模块classname
        },
        {
            name: '进行中', //name
            id: '34', //唯一标识
            type_style: '1', //类别
            size: '4', //数量  
            list_name: 'list-row', //右侧模块classname
        },
        {
            name: '已结束', //name
            id: '35', //唯一标识
            type_style: '1', //类别
            size: '4', //数量  
            list_name: 'list-row', //右侧模块classname
        },
        {
          name: '一键求助', //name
          id: '2222', //唯一标识
          type_style: '2', //类别
          size: '1', //数量  
          list_name: 'list-button' //右侧模块classname
        },
    ];

    function getMenus(page, number) {
        if (typeof number == 'number') {
            // modelIndex.mainContainerId = leftData[number].list_name;
        }
        left.paint(page, number);
    }

    function getMessage(id, page, pos, index) { //id,类型，页码，上下页，位置
      if (id == '666') {
        var param = {
          page: page,
          pagesize: modelIndex.pageSize,
          // cid: TV.GetParam('id'),
          // area_id: $.cookie('TV_CST_AREA'),
          // device: 'tv'
      }
      GetDatas('orderList', param, function (err, res) {
          var mess = res.data;
          var str = '';
          console.log(mess)
          if (mess.items.length > 0) {
            for (var i = 0; i < mess.items.length; i++) {
                str += '<div class="list-row" data-id="'+ mess.items[i].id +'"><div class="list-info">'
                //图片                      
                var img = '';
                if (mess.items[i].img == '') {
                    img = '../images/base.png'
                } else {
                    img = API_URL.imgURL + mess.items[i].img
                }
                str += '<div class="list-imgBar">'
                str += "<img class='list-img' src=" + img + ">";
                str += '</div>'
                //标题
                str += "<div class='list-title'><p class='ell'>" + mess.items[i].title + "</p></div>";
                str +="<div class='list-brief'>" + mess.items[i].tpe_name + "</div>"
                str += "<div class='list-time'>" + mess.items[i].periods.activity_time + "</div>"
                str += '</div>'

                //点单
                str += '<div class="list-count">'
                str += '已点单'
                str += '<div class="list-number">' + mess.items[i].counts +'次</div>'
                str += '</div>'
                str += '</div>'
              }
          } else {
              str += '<h1>暂无数据</h1>';
              $('#page_show').css('display', 'none');
          }
          $('#' + modelIndex.mainContainerId).html(str);
          MessOpt(page, mess.totalpage, pos, index,'run','ell');
        })
      }else if (id == '2222') {
        var params ={
          pageSize:7
        }
        GetDatas('getHelpWall', params, function (err, res) {
          var str = '';
          // console.log(res);
          var mess = res.data;
          console.log(mess)
          if(mess.items && mess.items.length) {
            str +='<marquee id="marquee" direction="up" scrollamount="5">'
            for(var i = 0; i <mess.items.length;i++){
              str += "<div class='ruleTitle'>" + mess.items[i].content + "</div>"
            }
            str += '</marquee>'
          }
          else {
            str += '<h1>暂无数据</h1>'
          }
          str += '<div class="list-button" data-status="0">我要求助</div>'
          str += '<div class="list-qrcode">扫码求助</div>'
          // str += "<div class='ruleTitle'>" + res.data.title + "</div>"
          // str += "<div  class='ruleContent'>11</div>"
          $('#' + modelIndex.mainContainerId).html(str);
          $('.page-show').css('display', 'none')
          MessOpt(1, 1, pos, index);
        })
      }
      else {
        var status;  
        if(id == '33'){
          var params = {
            // cid: id,
            page: page,
            status:1,
            is_menu: 1,
            pagesize: modelIndex.pageSize,
            month: modelIndex.menuKey || ''
            // area_id: $.cookie('TV_CST_AREA')
        }
        }else if(id == '34'){
          var params = {
            // cid: id,
            page: page,
            status:2,
            is_menu: 1,
            pagesize: modelIndex.pageSize,
            month: modelIndex.menuKey || ''
            // area_id: $.cookie('TV_CST_AREA')
        }
        }else if(id == '35'){
          var params = {
            // cid: id,
            page: page,
            status:3,
            is_menu: 1,
            pagesize: modelIndex.pageSize,
            month: modelIndex.menuKey || ''
            // area_id: $.cookie('TV_CST_AREA')
        }
        }else{
          params = {
            // cid: id,
            page: page,
            is_menu: 1,
            is_menu: 1,
            pagesize: modelIndex.pageSize,
            month: modelIndex.menuKey || ''
            // area_id: $.cookie('TV_CST_AREA')
          }
        }

        GetDatas('getActivityList', params, function (res, data) {
          var mess = data.data;
          console.log(mess.items,id)
          var str = '';
          if (mess.items.length) {
            $('.page-show').css('display', 'block')
            for (var i = 0; i < mess.items.length; i++) {
              str += '<div class="' + modelIndex.mainlistName + '" data-id=' + mess.items[i].id +" data-tpe=" + mess.items[i].tpe + " >";
                if(modelIndex.mainlistName == 'list-row'){
                  str += '<div class="list-info">'
                  //图片                      
                  var img = '';
                  if (mess.items[i].images == '') {
                      img = '../images/base.png'
                  } else {
                      img = API_URL.imgURL + mess.items[i].images
                  }
                  str += '<div class="list-imgBar">'
                  str += "<img class='list-img' src=" + img + ">";
                  str += '</div>'
                  //标题
                  str += "<div class='list-title'><p class='ell'>" + mess.items[i].title + "</p></div>";
                  str +="<div class='list-brief'>" + mess.items[i].address + "</div>"
                  str += "<div class='list-time'>"+ mess.items[i].format_start_time +' - ' + mess.items[i].format_end_time + "</div>"
                  str += "<div class='list-view'><img src='../images/view.png'>"
                  str += "<span>"+mess.items[i].click_count + "</span></div>"
                  str += "<div class='list-like'><img src='../images/like.png'>"
                  str += "<span>"+mess.items[i].likes + "</span></div>"
                  str += '</div>'

                  //收藏
                  // str += '<div class="list-collection">'
                  // str += '<img src="../images/collection.png">'
                  // str += '<div class="list-number">' + mess.items[i].likes +'</div>'
                  // str += '</div>'
                  str += '</div>'
                }
                else if(modelIndex.mainlistName =='list-video'){
                  var img = '';
                  if (mess.items[i].img == '') {
                      img = '../images/base.png'
                  } else {
                      img = API_URL.imgURL + mess.items[i].img
                  }
                  str += '<div class="list-imgBar">'
                  str += "<img class='list-img' src=" + img + ">";
                  str += '</div>'
                  if (mess.items[i].tpe == 5 || mess.items[i].tpe == 4) {
                    str += "<div class='listPlay' ><img src='../images/play.png'></div>";
                  }
                  str += "<div class='list-title'><p class='ell'>" + mess.items[i].title + '</p></div>'
                  str += '</div>'
                }            
            }
          } else {
              str = '<h1>暂无数据</h1>'
              $('.page-show').css('display', 'none')
          }
          $('#' + modelIndex.mainContainerId).html(str);
          MessOpt(page, mess.totalpage, pos, index,'run','ell');
        })
      }
    }

    function direEnter(status, id, index) {
        var tpe = $('.active').attr('data-tpe');
        if (id == '666') {
          window.location.href = 'orderDetail.html?id=' + $('.active').attr('data-id');
          return
        }else if (id == '2222') {
          var access_token = $.cookie('TV_CST_TOKEN');
          var param = {
            title:1,
            access_token : access_token,
          }
          GetDatas('appeal', param, function (err, res) {
            console.log(res)
              if (res.code == 0) {
                  TV.PromptMsg('求助成功')
                  $(".cur-number").eq(index).html(res.data.likes);
                  // $('#like').css('background-image','url(../images/like-2.png)')
              } else if (res.code == 10009) {

                  TV.userLogin();
                  direEnter(index);
                  // alert('111')
              } else {
                  var message = res.message
                  TV.PromptMsg(message)
                    }
                })
        }else {
          window.location.href = "activeDetail.html?id=" + $('.active').attr('data-id');
        }
          // return

    }
</script>
<script type="text/javascript" src="../js/twoPageList.js"></script>

</html>